﻿using System;
using System.Collections.Generic;
using TouchSocket.Core;
using TouchSocket.Sockets;

namespace TK.TSocket
{
    /// <summary>
    /// TcpSocketServerConfig
    /// </summary>
    public class TcpSocketServerConfig
    {
        /// <summary>
        /// 监听IP及端口列表,未设置默认监听 本机所有IP:50000
        /// </summary>
        public List<IPHost> IpHostList { get; } = new List<IPHost>();

        /// <summary>
        /// 数据适配器放置阶段,与DataAdapterFunc配合使用
        /// </summary>
        public AdapterActionType ActionType { get; set; } = AdapterActionType.Connect;

        /// <summary>
        /// ip白名单，优先级最高；设置了此值，白名单之外的IP一概拒绝连接
        /// </summary>
        public List<string> IpWhiteList { get; } = new List<string>();

        /// <summary>
        /// ip黑名单，优先级低于白名单；设置了此值，黑名单内的IP一概拒绝连接
        /// </summary>
        public List<string> IpBlackList { get; } = new List<string>();

        /// <summary>
        /// 与ActionType配合使用；数据处理协议，处理tcp粘包、半包行为；
        /// 此处可根据不连接增加没同的数据协议，具体数据协议查看touchsocket文档;
        /// </summary>
        public Func<TcpAdapterConfig, DataHandlingAdapter> DataAdapterFunc { get; set; }

        /// <summary>
        /// 此处可自定义相关设置;切记不要与上面的配置重复设置
        /// </summary>
        public Action<TouchSocketConfig> AdvanceAction { get; set; }
    }
}
